package entry;

import java.io.*;
import java.net.Socket;

/***
 *  客户端：读取文本文件数据发送到服务器端
 */
public class ClientTcp {
    static private String serverIp = "127.0.0.1";
    static private int hostPort = 12345;

    public static void main(String[] args) throws IOException {
        Socket s = new Socket(serverIp,hostPort);


        Socket sss = new Socket("127.0.0.1",12345);


        BufferedReader br = new BufferedReader(new FileReader("src\\main\\resources\\data.txt"));
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));




        String line;
        while ((line = br.readLine())!=null){
            bw.write(line);
            bw.newLine();
            bw.flush();
        }

        s.shutdownOutput();

        //接收反馈
        BufferedReader brClient = new BufferedReader(new InputStreamReader(s.getInputStream()));
        String dataResult = brClient.readLine();// 等待读取数据
        System.out.println(dataResult);

        br.close();
        s.close();

    }
}
